package com.anuo.app.study.studyjava;

/**
 * 主要有3 种方法引用(Method Reference)
 * # 引用静态方法
 * # 引用实例方法
 * # 引用构造函数(见下面链接,搜索constructor)
 * 参考: https://www.javatpoint.com/java-8-method-reference
 */
public class StudyMethodReference
{
    public static void main(String[] args) {
        studyReferStaticMethod();
    }

    //引用实例方法
    public static void studyReferInstanceMethod(){
        Sayable sayable=new StudyMethodReference() :: sayBye;
        sayable.say();
    }

    //引用静态方法
    public static void studyReferStaticMethod(){
        Sayable sayable=StudyMethodReference :: sayHello;
        sayable.say();
    }

    public static void sayHello(){
        System.out.println("hello");
    }

    public void sayBye(){
        System.out.println("bye");
    }

    interface Sayable{
        void say();
    }
}


